package com.htgd.gardenexpo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.htgd.gardenexpo.entity.GeMyAddress;
import com.htgd.gardenexpo.dao.GeMyAddressDao;
import com.htgd.gardenexpo.page.AddressQuery;
import com.htgd.gardenexpo.service.GeMyAddressService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 常用地址 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-05-22
 */
@Service
public class GeMyAddressServiceImpl extends ServiceImpl<GeMyAddressDao, GeMyAddress> implements GeMyAddressService {

    @Autowired
    private GeMyAddressDao geMyAddressDao;

    @Override
    public PageInfo<GeMyAddress> queryList(AddressQuery addressQuery) {
        PageHelper.startPage(addressQuery.getPageNum(), addressQuery.getPageSize());
        List<GeMyAddress> list = geMyAddressDao.querylist(addressQuery);
        for (GeMyAddress geMyAddress : list) {
            geMyAddress.setOpenId("");
        }
        return new PageInfo<>(list);
    }

    @Override
    public void changeAllStatus(Integer id) {
        lambdaUpdate().ne(GeMyAddress::getId,id)
                .set(GeMyAddress::getStatus,0)
                .update();
    }
}
